<% add_decidim_meta_tags(
  description: translated_attribute(current_component.participatory_space.try(:description)),
  title: t("decidim.components.pagination.page_title",
           component_name: component_name,
           current_page: paginate_posts.current_page,
           total_pages: paginate_posts.total_pages ),
  url: posts_url,
  resource: current_component) %>

<%= append_javascript_pack_tag "decidim_blogs" %>
<%= append_stylesheet_pack_tag "decidim_blogs" %>

<% content_for :aside do %>
  <h1 class="title-decorator"><%= component_name %></h1>

  <% if allowed_to?(:create, :blogpost) %>
      <%= action_authorized_link_to :create, new_post_path, permissions_holder: current_component, class: "button button__xl button__secondary w-full", data: { "redirect_url" => new_post_path } do %>
        <span><%= t("new_post", scope: "decidim.blogs.posts.index") %></span>
        <%= icon "add-line" %>
      <% end %>
  <% end %>
<% end %>

<%= render layout: "layouts/decidim/shared/layout_two_col" do %>

  <%= render partial: "decidim/shared/component_announcement" %>

  <section id="blogs" class="layout-main__section layout-main__heading">
    <% if posts.empty? %>
      <%= cell("decidim/announcement", t("empty", scope: "decidim.blogs.posts.index")) %>
    <% else %>
      <h2 class="h5 md:h3 decorator"><%= t("count", scope: "decidim.blogs.posts.index", count: posts.length) %></h2>
    <% end %>

    <% paginate_posts.each do |post| %>
      <%= card_for post, size: :l %>
    <% end %>

    <%= decidim_paginate paginate_posts %>
  </section>

<% end %>
